package net.wisos.opn.admin.service;

import java.util.List;

import net.wisos.opn.admin.dao.AdministratorDao;
import net.wisos.opn.admin.entity.Administrator;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
@Transactional(readOnly = true)
public class AdministratorManager {
	@Autowired
	private AdministratorDao sysUserDao;

	@Transactional(readOnly = false)
	public void saveSysUser(Administrator sysUser) {
		sysUserDao.save(sysUser);
	}

	public Administrator getSysUser(Long id) {
		return sysUserDao.findOne(id);
	}

	@Transactional(readOnly = false)
	public void deleteSysUser(Long id) {
		sysUserDao.delete(id);
	}

	public List<Administrator> getAllSysUser() {
		return (List<Administrator>) sysUserDao
				.findAll(new Sort(Direction.ASC, "id"));
	}

}
